package trunk.firstSec;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.MapReduceBase;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reducer;
import org.apache.hadoop.mapred.Reporter;

import java.io.IOException;
import java.util.Iterator;

public class daReducer extends MapReduceBase implements Reducer<Text, IntWritable, Text, outputStringWrapper>{
    private outputStringWrapper valueOut;
    @Override
    public void reduce(Text key, Iterator<IntWritable> values, OutputCollector<Text, outputStringWrapper> output, Reporter reporter) throws IOException {
        int value;
        valueOut = new outputStringWrapper();
        while( values.hasNext() ) {
            if ((value = values.next().get()) != -1)
                valueOut.appendOffset(String.valueOf(value));
        }
        output.collect(key, valueOut);
    }
}
